home *** CD-ROM | disk | FTP | other *** search
- Path: news.Gsu.EDU!gs01lmh
- From: gs01lmh@panther.Gsu.EDU (Louis Miller Hall)
- Newsgroups: comp.lang.c++
- Subject: Need some simple help with C++
- Date: 22 Feb 1996 17:10:12 GMT
- Organization: Georgia State University
- Message-ID: <4gi81k$ebb@sphinx.Gsu.EDU>
- NNTP-Posting-Host: panther.gsu.edu
- NNTP-Posting-User: gs01lmh
- X-Newsreader: TIN [version 1.2 PL2]
-
- I am having a problem getting the following code to reuse a string so
- that I can put and print various info into it, when the program runs, it
- will successfully output the data the first time through the loop, but
- after that, it will continue to run, but not allow you to enter another
- string, and moreover outputs an empty string??!!!? Can anybody tell me
- what I am doing wrong:
-
- #include <fstream.h>
-
- char *name;
- int a = 1;
-
- void main ()
- {
- while (a)
- {
- name = new char[80];
- cout << "What is the string >" << endl;
- cin.getline(name, 80);
- cout << "The string entered is >" << name << endl;
- cout << "Enter 0 to quit, any other to continue>";
- cin >> a;
- delete name; // will work the same with or without this
- } // while
- } // main
-
- I have also tried using char name[80]; but this too fails, I am trying to
- teach myself C++, and any addtional help I could get would be
- appreciated.
-
- Thanks
-
-